/**
 * Copyright  (c) 2009-2010 Wilmar IT Service,  Inc.   
 * All  rights  reserved. 
 */
package com.wilmar.process.entity.comparator;

import java.io.Serializable;
import java.util.Comparator;

import com.wilmar.process.entity.Attachement;

/**
 * @author MaKuBEX Email:makubexnet@gmail.com
 * @version 1.0.0 Apr 12, 2010
 * @since 1.0.0
 * 
 */
public class AttachementComparator implements Serializable,
		Comparator<Attachement> {

	/**
	 * @serialField
	 */
	private static final long serialVersionUID = 4250598744187846558L;

	/**
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	public int compare(Attachement arg0, Attachement arg1) {
		if (arg0.getUploadTime() == null)
			return -1;
		else if (arg1.getUploadTime() == null)
			return 1;
		else if (arg0.getUploadTime().before(arg1.getUploadTime()))
			return 1;
		else if (arg0.getUploadTime().after(arg1.getUploadTime()))
			return -1;
		else
			return 0;
	}

}
